import torch
import sys
import os

# 添加项目根目录到Python路径
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from src.operators.asecondc import AsecondC
from src.utils.visualization import plot_feature_maps, plot_comparison

def main():
    # 创建一个示例输入
    batch_size = 1
    in_channels = 3
    height = 32
    width = 32
    
    # 创建随机输入数据
    x = torch.randn(batch_size, in_channels, height, width)
    
    # 初始化AsecondC算子
    asecondc = AsecondC(
        in_channels=in_channels,
        out_channels=16,
        kernel_size=3,
        stride=1,
        padding=1
    )
    
    # 前向传播
    output = asecondc(x)
    
    print("输入形状:", x.shape)
    print("输出形状:", output.shape)
    
    # 可视化结果
    print("\n可视化输入特征图...")
    plot_feature_maps(x[0], title="Input Feature Maps")
    
    print("\n可视化输出特征图...")
    plot_feature_maps(output[0], title="Output Feature Maps")
    
    print("\n对比输入和输出...")
    plot_comparison(x[0], output[0], title="AsecondC Input vs Output")

if __name__ == "__main__":
    main() 